package com.xmy.cultivate.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.xmy.cultivate.entity.OrderDetail;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xmy.cultivate.entity.Organization;
import com.xmy.cultivate.entity.Subjects;
import com.xmy.cultivate.entity.views.EnrollList;
import com.xmy.cultivate.entity.views.FirstSignUp;
import com.xmy.cultivate.entity.views.IncomeDayReport;
import com.xmy.cultivate.entity.views.ResApplyGather;
import com.xmy.cultivate.respons.IncomeDailyRs;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 订单报名信息 服务类
 * </p>
 *
 * @author min
 * @since 2022-08-01
 */
public interface IOrderDetailService extends IService<OrderDetail> {


    public abstract IPage<EnrollList> getEnrollList(IPage<?> page, Wrapper wrapper);

    public abstract Map<String, BigDecimal> enrollListMoney(Wrapper wrapper);

    public abstract List<OrderDetail> orderDetail(Wrapper wrapper);

    public abstract Integer getApplyCountForSubjects(Long schoolId, Long studentId, Long subjectsId, Integer newYeartPart, Integer newNum, Integer lessonType);

    public abstract OrderDetail getLastOneForStudent(Long schoolId, Long studentId, Long subjectsId, Integer yearPart, Integer quarterNum, Integer lessonType);

    public abstract List<OrderDetail> GetLessonByStuInfoId(Wrapper wrapper);

    public abstract List<Subjects> GetSubjectsByStuInfoId(Wrapper wrapper);


    /**
     * 报读通过课程，获取在读信息
     *
     * @param courseId
     * @param studentId
     * @return
     */
    public abstract List<OrderDetail> getLessonByCourseId(Long courseId, Long studentId, Long schoolId);

    Integer getAllCourseCountForSubjects(Long schoolId, Long studentId, Long subjectsId, Integer yearAndQuarter, Integer lessonType);

    /**
     * 报读通过科目，获取在读信息
     *
     * @param subjectsId
     * @param studentId
     * @return
     */
    public abstract List<OrderDetail> getLessonForSubjects(Long subjectsId, Long studentId, Long schoolId, Integer lessonType);

    /**
     * 获取报读校区
     *
     * @param wrapper
     * @return
     */
    public abstract List<Organization> getSignUpSchoolListForWhere(@Param(Constants.WRAPPER) Wrapper wrapper);

    public abstract FirstSignUp getFirstSignUp(Long studentId, Long gradeId, Integer count);


    public abstract Boolean stopCourse(Long orderDetailId);

    public abstract IPage<IncomeDayReport> getIncomeDayReport(IPage<?> page, Wrapper wrapper, Integer readType, String payNum);

    IPage<IncomeDayReport> getDisList(IPage<?> page,
                                      Integer yearPart,
                                      Integer quarterNum,
                                      List<Long> schoolIdList,
                                      String subjectsId,
                                      String status,
                                      String studentName,
                                      String lessonType,
                                      List<Integer> yearClassIdList,
                                      String handlePersonId,
                                      String startDate,
                                      String endDate,
                                      String orderType,
                                      String payeeId,
                                      String inviteId,
                                      String teacherId
    );


    BigDecimal getDisPrice(
            Integer yearPart,
            Integer quarterNum,
            List<Long> schoolIdList,
            String subjectsId,
            String status,
            String studentName,
            String lessonType,
            List<Integer> yearClassIdList,
            String handlePersonId,
            String startDate,
            String endDate,
            String orderType,
            String payeeId,
            String inviteId,
            String teacherId
    );

    public abstract BigDecimal getSolidStatisticsPrice(Wrapper wrapper);

    public abstract BigDecimal getStatisticsPrice(@Param(Constants.WRAPPER) Wrapper wrapper);

    public abstract IPage<ResApplyGather> applyGatherForPage(Wrapper wrapper, IPage<OrderDetail> page);

    public abstract List<ResApplyGather> applyGatherList(Wrapper wrapper);

    public abstract List<OrderDetail> getBigFifteeList();

    public abstract Integer getUseCourseHouse(Wrapper wrapper);

    public abstract BigDecimal getAllResiduePrice(Long schoolId, Long studentId, Long subjectsId, Integer yearAndQuarter, Integer lessonType);

    public abstract Integer getResidueCourseCount(Long schoolId, Long studentId, Long subjectsId, Integer yearAndQuarter, Integer lessonType);

    public abstract List<OrderDetail> getOrderDetailForResidueCoruseCount();

    /**
     * 自动添加智能课
     *
     * @param yearPart
     * @param quarterNum
     * @param schoolId
     * @param subjectsId
     * @param lessonType
     * @param studentId
     * @return
     */
    public void addOrderApply(Integer yearPart, Integer quarterNum, Long schoolId, Long subjectsId, Integer lessonType, Long studentId);


    /**
     * 报科目人数
     *
     * @return
     */
    public abstract List<OrderDetail> countStudentsBySubject();

    /**
     * 学员总人数
     *
     * @return
     */
    public abstract Integer countStudent();


    List<OrderDetail> getTransferOrderDetail(Integer yearPart,
                                             Integer quarterNum,
                                             String schoolId,
                                             Integer lessonType);

    List<OrderDetail> getLastOrderListForStudent();

    void updateStudentResidueCourseCount(Integer yearPart, Integer quarterNum, Long studentId);

    public abstract IncomeDailyRs getIncomeDailyRsCount(Wrapper wrapper);

}
